package cn.yc.transformation;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.file.Files;
import java.nio.file.Paths;

public class OutputStreamWriter_ {
    public static void main(String[] args) throws IOException {
        String filePath = "e:\\io\\out.txt";
        String charset = "utf8";
        OutputStreamWriter osw = new OutputStreamWriter(Files.newOutputStream(Paths.get(filePath)),charset);
        osw.write("hi,你好编程");
        osw.close();
        System.out.println("按照"+charset+"格式保存文件完成");
    }
}
